﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace IBuy.Entity
{
    public class Configuration
    {
        public static string GetSystemLogLocation()
        {
            try
            {
                XmlDocument config = new XmlDocument();
                config.Load(@"d:\Database\Config.xml");
                XmlNode root = config.SelectSingleNode("Configuration");
                XmlNodeList listNodes = root.ChildNodes;
                return listNodes[0].InnerText;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public static string GetUserLogLocation()
        {
            try
            {
                XmlDocument config = new XmlDocument();
                config.Load(@"d:\Database\Config.xml");
                XmlNode root = config.SelectSingleNode("Configuration");
                XmlNodeList listNodes = root.ChildNodes;
                return listNodes[1].InnerText;
            }
            catch (Exception e)
            { return null; }
        }

        public static string GetLogDegree()
        {
            try
            {
                XmlDocument config = new XmlDocument();
                config.Load(@"d:\Database\Config.xml");
                XmlNode root = config.SelectSingleNode("Configuration");
                XmlNodeList listNodes = root.ChildNodes;
                return listNodes[2].InnerText;
            }
            catch (Exception e)
            { return null; }
        }

        public static void SetSystemLogLocation(string location)
        {
            try
            {
                XmlDocument config = new XmlDocument();
                config.Load(@"d:\Database\Config.xml");
                XmlNode root = config.SelectSingleNode("Configuration");
                XmlNodeList listNodes = root.ChildNodes;
                listNodes[0].InnerText = location;
            }
            catch (Exception e)
            { }
        }

        public static void SetUserLogLocation(string location)
        {
            try
            {
                XmlDocument config = new XmlDocument();
                config.Load(@"d:\Database\Config.xml");
                XmlNode root = config.SelectSingleNode("Configuration");
                XmlNodeList listNodes = root.ChildNodes;
                listNodes[1].InnerText = location;
            }
            catch (Exception e)
            { }
        }

        public static void SetLogDegree(string Degree)
        {
            try
            {
                XmlDocument config = new XmlDocument();
                config.Load(@"d:\Database\Config.xml");
                XmlNode root = config.SelectSingleNode("Configuration");
                XmlNodeList listNodes = root.ChildNodes;
                listNodes[2].InnerText = Degree;
            }
            catch (Exception e)
            { }
        }
    }
}
